package com.yitao.cms.constant.order;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OrderEnums {

    /**
     * 退款状态
     */
    public enum RefundStatusEnums {

        CANCELED(-20, "驳回退款"),
        REFUND_FINISHED(-40, "确认退款"),
        OFFLINE_REFUND(-60, "线下退款");

        private static final Map<Integer, RefundStatusEnums> map = new HashMap<>();

        static {
            RefundStatusEnums[] values = RefundStatusEnums.values();
            for (RefundStatusEnums iten : values) {
                map.put(iten.code, iten);
            }
        }

        private final Integer code;
        private final String name;

        private RefundStatusEnums(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static RefundStatusEnums getEnum(Integer code) {
            return map.get(code);
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 退款列表tab展示枚举
     */
    public enum REFUND_STATUS {
        STANDARD_ORDER(0, "全部"),
        APPLYING_FOR_REFUND(-10, "申请退款中"),
        NOT_REFUND(-20, "退款中"),
        REFUND(-30, "已退款"),
        REFUND_ERROR(-40, "退款失败");

        private final Integer code;
        private final String name;
        private static final List<Map<String, Object>> list = new ArrayList<>();

        static {
            for (OrderEnums.REFUND_STATUS refund_status : OrderEnums.REFUND_STATUS.values()) {
                Map<String, Object> map = new HashMap<>();
                map.put("key", refund_status.getCode());
                map.put("value", refund_status.getName());
                list.add(map);
            }
        }

        REFUND_STATUS(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public static List<Map<String, Object>> getRefundEnum() {
            return list;
        }
    }

    public enum REFUND_SEARCH_ENUM {
        PRODUCT_NAME(1, "商品名"),
        RECIPIENT_NAME(2, "收件人姓名"),
        RECIPIENTC_PHONE(3, "收件人手机"),
        ORDER_CODE(4, "订单号");

        private final Integer code;
        private final String name;
        private static final List<Map<String, Object>> list = new ArrayList<>();

        static {
            for (OrderEnums.REFUND_SEARCH_ENUM refund_search_enum : OrderEnums.REFUND_SEARCH_ENUM.values()) {
                Map<String, Object> map = new HashMap<>();
                map.put("key", refund_search_enum.getCode());
                map.put("value", refund_search_enum.getName());
                list.add(map);
            }
        }

        REFUND_SEARCH_ENUM(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        public static List<Map<String, Object>> getRefundSearchEnum() {
            return list;
        }
    }


    public enum OrderListSearchEnum {

        TRADE_NAME(1, "商品名"),
        CONTACTER_NAME(2, "收货人姓名"),
        MOBILE(3, "收货人手机"),
        WAYBILL_NUMBER(4, "运单号"),
        ORDER_CODE(5, "订单号"),
        BRAND(6, "品牌"),
        USER_NAME(7, "用户名");

        private static final Map<Integer, OrderListSearchEnum> map = new HashMap<>();

        static {
            OrderListSearchEnum[] values = OrderListSearchEnum.values();
            for (OrderListSearchEnum iten : values) {
                map.put(iten.code, iten);
            }
        }

        private final Integer code;
        private final String name;

        private OrderListSearchEnum(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static OrderListSearchEnum getEnum(Integer code) {
            return map.get(code);
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }


    /**
     * 退款状态
     */
    public enum PayTypeName {

        DEFAULT(-1, "— —"),
        WECHAT(1, "微信"),
        BANK_CARD(2, "银行卡"),
        OFFLINE(3, "线下");

        private static final Map<Integer, PayTypeName> map = new HashMap<>();

        static {
            PayTypeName[] values = PayTypeName.values();
            for (PayTypeName iten : values) {
                map.put(iten.code, iten);
            }
        }

        private final Integer code;
        private final String name;

        private PayTypeName(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static PayTypeName getEnum(Integer code) {
            return map.get(code);
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

}
